﻿

using System.Windows.Input;

namespace GaleSong
{
    /// <summary>
    ///     A part that can be used as both <see cref="MenuPart" /> and <see cref="ToolBarPart" />.
    /// </summary>
    public class MenuToolPart : PartBase, IMenuPart, IToolBarPart, IObservableParent<IMenuPart>,
        IObservableParent<IToolBarPart>
    {
        #region Constructor

        public MenuToolPart()
        {
        }

        public MenuToolPart(string name)
            : base(name)
        {
        }

        #endregion

        #region PartBase

        public override void Execute()
        {
            var statusBar = IoC.Get<ILogService>();
            statusBar.ShowMessage(DisplayName);
        }

        #endregion

        #region IToolBarPart Members

        private string toolTip;

        public string ToolTip
        {
            get { return toolTip; }
            set
            {
                toolTip = value;
                NotifyPropertyChanged(() => ToolTip);
            }
        }

        #endregion

        #region IPartParent<IMenuPart> Members

        private readonly BindableCollection<IMenuPart> menus = new BindableCollection<IMenuPart>();

        IObservableCollection<IMenuPart> IObservableParent<IMenuPart>.Items
        {
            get { return menus; }
        }

        #endregion

        #region IPartParent<IToolBarPart> Memebers

        private readonly BindableCollection<IToolBarPart> toolbars = new BindableCollection<IToolBarPart>();

        IObservableCollection<IToolBarPart> IObservableParent<IToolBarPart>.Items
        {
            get { return toolbars; }
        }

        #endregion

        #region ISeparaterPart Members

        private bool _isSeparator;

        public bool IsSeparator
        {
            get { return _isSeparator; }
            private set
            {
                _isSeparator = value;
                NotifyPropertyChanged(() => IsSeparator);
            }
        }

        #endregion

        #region ICheckable Members

        private KeyGesture _keyGesture;

        public KeyGesture KeyGesture
        {
            get { return _keyGesture; }
            set
            {
                _keyGesture = value;
                NotifyPropertyChanged(() => KeyGesture);
            }
        }

        private bool _isCheckable;

        public bool IsCheckable
        {
            get { return _isCheckable; }
            set
            {
                _isCheckable = value;
                NotifyPropertyChanged(() => IsCheckable);
            }
        }

        private bool _isChecked;
        public bool IsChecked
        {
            get { return _isChecked; }
            set
            {
                _isChecked = value;
                NotifyPropertyChanged(() => IsChecked);
            }
        }

        #endregion
    }
}